import { onMounted } from "vue"
const { ipcRenderer } = require("electron")

export const useInitEvent = () => {
  const getPostion = () => {
    const pos = window.localStorage.getItem("position") || '0,0'
    ipcRenderer.send("setPosition", pos.split(','))
  }

  // 保存当前位置
  const savePosition = () => {
    ipcRenderer.on("getPositon", (_, pos) => {
      window.localStorage.setItem("position", pos.join(','))
    })
  }

  onMounted(() => {
    getPostion()
    savePosition()
  })
}


